--[[/**
-- * 
 * 提高伤害--敌我双方每有英雄死亡时
-- *
-- */]]

---@class BuffEffect264100 : BaseBuffEffect
BuffEffect264100 = ClientFight.CreateClass("BuffEffect264100", ClientFight.BaseBuffEffect)
local t = BuffEffect264100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local source = buff.source;
    local fightResult = parameters[3];
    local oneRatio = buff.getBuffBean().getF_BuffEffectValue()[0];
    local maxRatio = buff.getBuffBean().getF_BuffEffectValue()[1];

    if (fightResult.damage <= 0) then
        return IBuffEffect.FAIL;
    end

    local dieAmount = 0;
    local fighters = fight.team[source.teamIndex].fighters;
    for k, fighter in pairs(fighters) do
        if (fighter:isSummons()) then
            goto continue;
        end
        if (fighter:isDie()) then
            dieAmount = dieAmount + 1;
        end
        :: continue ::
    end
    fighters = fight.team[3 - source.teamIndex].fighters;
    for k, fighter in pairs(fighters) do
        if (fighter:isSummons()) then
            goto continue1;
        end
        if (fighter:isDie()) then
            dieAmount = dieAmount + 1;
        end
        :: continue1 ::
    end

    if (dieAmount <= 0) then
        return IBuffEffect.FAIL;
    end

    local calculateRatio = math.min(oneRatio * dieAmount, maxRatio) / 10000 + 1;
    fightResult.damage = fightResult.damage * calculateRatio;

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()